# -*- coding: utf-8 -*-
import numpy as np

if __name__ == '__main__':
    # ndarray的矢量化
    arange = np.arange(3)
    np_arange = np.arange(3, 6)
    print arange
    print np_arange
    print arange+np_arange
    print 2*arange
    # ndarray的切片
    n = np.arange(12)
    print n
    print n[2:4]
    reshape = n.reshape(3, 4)
    print reshape
    print reshape[1]
    print reshape[:2, 2:4]
    #条件索引
    year_array = np.array([[2000, 2001, 2002], [2003, 2004, 2005], [2006, 2007, 2008]])
    print year_array
    is_year_after_2004 = year_array>2004
    print is_year_after_2004
    # 最后的数组是一维数组
    print year_array[is_year_after_2004]